package com.ktgj.customer.service.impl;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.text.Simhash;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.Temperature;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ktgj.common.core.annotation.Excel;
import com.ktgj.common.core.constant.TravelConstants;
import com.ktgj.common.core.enums.EmHelper;
import com.ktgj.common.core.utils.DateUtils;
import com.ktgj.customer.common.FieldConstant;
import com.ktgj.customer.domain.*;
import com.ktgj.customer.domain.vo.*;
import com.ktgj.customer.mapper.*;
import com.ktgj.customer.service.*;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;

/**
 * 旅游团Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-10-26
 */
@Service
public class TravelGroupServiceImpl implements ITravelGroupService 
{
    @Autowired
    private TravelGroupMapper travelGroupMapper;

    @Autowired
    private TravelCommentMapper travelCommentMapper;

    @Autowired
    private TravelProductMapper travelProductMapper;

    @Autowired
    private TravelGroupLabelMapper travelGroupLabelMapper;

    @Autowired
    private TravelItinerarySummaryMapper travelItinerarySummaryMapper;

    @Autowired
    private TravelItineraryMapper travelItineraryMapper;

    @Autowired
    private TravelItineraryInfoMapper travelItineraryInfoMapper;

    @Autowired
    private TravelItineraryPictureMapper travelItineraryPictureMapper;

    @Autowired
    private TravelCommentPictureMapper travelCommentPictureMapper;

    @Autowired
    private OrderInfoMapper orderInfoMapper;

    @Autowired
    private TravelGroupNumberMapper travelGroupNumberMapper;

    @Autowired
    private ILoginService loginService;

    @Autowired
    private IDepositBusinessService depositBusinessService;

    @Autowired
    private AssistProductMapper assistProductMapper;

    @Autowired
    private CouponSpecificMapper couponSpecificMapper;

    @Autowired
    private CouponMapper couponMapper;

    @Autowired
    private TravelSupplierMapper travelSupplierMapper;

    @Autowired
    private TravelContractMapper travelContractMapper;

    @Autowired
    private IPointRecordService pointRecordService;

    /**
     * 查询旅游团
     * 
     * @param groupId 旅游团ID
     * @return 旅游团
     */
    @Override
    public TravelGroup selectTravelGroupById(Long groupId)
    {
        TravelGroup travelGroup = travelGroupMapper.selectTravelGroupById(groupId);
        if (travelGroup != null)
        {
            List<TravelGroupLabel> lstGroupLabel = travelGroupLabelMapper.selectTravelGroupLabelByGroupId(travelGroup.getGroupId());
            if (CollectionUtil.isNotEmpty(lstGroupLabel))
            {
                travelGroup.getGroupLabelNameList().addAll(lstGroupLabel);
            }
            List<TravelItinerarySummary> lstItinerarySummary = travelItinerarySummaryMapper.selectTravelItinerarySummary(travelGroup.getGroupId());
            if (CollectionUtil.isNotEmpty(lstItinerarySummary))
            {
                travelGroup.getTravelItinerarySummaryVoList().addAll(lstItinerarySummary);
            }
            List<TravelItinerary> lstItinerary = travelItineraryMapper.selectTravelItinerary(travelGroup.getGroupId());
            if (CollectionUtil.isNotEmpty(lstItinerary))
            {
                for (TravelItinerary travelItinerary : lstItinerary)
                {
                    List<TravelItineraryInfo> lstItineraryInfo = travelItineraryInfoMapper.selectTravelItineraryInfo(travelItinerary.getTravelItineraryId());
                    if (CollectionUtil.isNotEmpty(lstItineraryInfo))
                    {
                        for (TravelItineraryInfo travelItineraryInfo : lstItineraryInfo)
                        {
                            List<TravelItineraryPicture> lstItineraryPicture = travelItineraryPictureMapper.selectTravelItineraryPicture(travelItineraryInfo.getTravelItineraryInfoId());
                            if (CollectionUtil.isNotEmpty(lstItineraryPicture))
                            {
                                travelItineraryInfo.getTravelItineraryPictureVoList().addAll(lstItineraryPicture);
                            }
                        }
                        travelItinerary.getItineraryDetailsVoList().addAll(lstItineraryInfo);
                    }
                }
                travelGroup.getSchedule().addAll(lstItinerary);
            }
        }
        return travelGroup;
    }

    /**
     * 查询旅游团列表
     * 
     * @param travelGroupDto 旅游团
     * @return 旅游团
     */
    @Override
    public List<TravelGroupDto> selectTravelGroupList(TravelGroupDto travelGroupDto)
    {
        return travelGroupMapper.selectTravelGroupList(travelGroupDto);
    }

    /**
     * 新增旅游团
     * 
     * @param travelGroupDto 旅游团
     * @return 结果
     */
    @Override
    public int insertTravelGroup(TravelGroupDto travelGroupDto)
    {
        travelGroupDto.setCreateTime(DateUtils.getNowDate());
        return travelGroupMapper.insertTravelGroup(travelGroupDto);
    }

    /**
     * 修改旅游团
     * 
     * @param travelGroupDto 旅游团
     * @return 结果
     */
    @Transactional
    @Override
    public int updateTravelGroup(TravelGroup travelGroupDto)
    {
        int rows = travelGroupMapper.updateTravelGroup(travelGroupDto);
        if (rows > 0)
        {
            travelGroupLabelMapper.deleteGroupLabelByGroupId(travelGroupDto.getGroupId());
            if (CollectionUtil.isNotEmpty(travelGroupDto.getGroupLabelNameList()))
            {
                for (TravelGroupLabel travelGroupLabel : travelGroupDto.getGroupLabelNameList())
                {
                    travelGroupLabelMapper.insertTravelGroupLabel(travelGroupLabel);
                }
            }
            travelItinerarySummaryMapper.deleteGroupSummaryById(travelGroupDto.getGroupId());
            if (CollectionUtil.isNotEmpty(travelGroupDto.getTravelItinerarySummaryVoList()))
            {
                travelItinerarySummaryMapper.insertBatch(travelGroupDto.getTravelItinerarySummaryVoList());
            }
            if (CollectionUtil.isNotEmpty(travelGroupDto.getSchedule()))
            {
                for (TravelItinerary travelItinerary : travelGroupDto.getSchedule())
                {
                    for (TravelItineraryInfo travelItineraryInfo : travelItinerary.getItineraryDetailsVoList())
                    {
                        travelItineraryPictureMapper.deleteItineraryPictureByItineraryInfoId(travelItineraryInfo.getTravelItineraryInfoId());
                    }
                    travelItineraryInfoMapper.deleteItineraryInfoByItineraryId(travelItinerary.getTravelItineraryId());
                }
                travelItineraryMapper.deleteGroupItineraryByGroupId(travelGroupDto.getGroupId());
                for (TravelItinerary travelItinerary :travelGroupDto.getSchedule())
                {
                    travelItinerary.setGroupId(travelGroupDto.getGroupId());
                    travelItineraryMapper.insertTravelItinerary(travelItinerary);
                    for (TravelItineraryInfo travelItineraryInfo :travelItinerary.getItineraryDetailsVoList())
                    {
                        travelItineraryInfo.setTravelItineraryId(travelItinerary.getTravelItineraryId());
                        travelItineraryInfoMapper.insertTravelItineraryInfo(travelItineraryInfo);
                        for (TravelItineraryPicture travelItineraryPicture : travelItineraryInfo.getTravelItineraryPictureVoList())
                        {
                            travelItineraryPicture.setTravelItineraryInfoId(travelItineraryInfo.getTravelItineraryInfoId());
                            travelItineraryPictureMapper.insertTravelItineraryPicture(travelItineraryPicture);
                        }
                    }
                }
            }
        }
        return rows;
    }

    /**
     * 批量删除旅游团
     * 
     * @param groupIds 需要删除的旅游团ID
     * @return 结果
     */
    @Override
    public int deleteTravelGroupByIds(Long[] groupIds)
    {
        return travelGroupMapper.deleteTravelGroupByIds(groupIds);
    }

    /**
     * 删除旅游团信息
     * 
     * @param groupId 旅游团ID
     * @return 结果
     */
    @Override
    public int deleteTravelGroupById(Long groupId)
    {
        return travelGroupMapper.deleteTravelGroupById(groupId);
    }

    @Override
    public List<TravelGroupListVo> queryGroupList() {
        return travelGroupMapper.queryGroupList();
    }

    /**
     * 查询旅游团详情
     * @param groupId
     * @return
     */
    @Override
    public TravelGroupDetailVo queryTravelGroupDetail(Long groupId) {
        //TODO lj 数据结构不清晰
        List<TravelComment> travelCommentList = travelCommentMapper.queryGroupCommentById(groupId);

        return null;
    }

    /**
     * 旅游产品列表
     * */
    @Override
    public List<TravelGroupVo> travelGroupVoList() throws Exception {
        List<TravelGroupVo> travelGroupVos = new ArrayList<>();
        List<TravelGroupDto> travelGroups = travelGroupMapper.travelGroupVoList();
        travelGroups = travelGroups.stream().filter(item->item.getGroupStatus().equals(TravelConstants.trues.getValue())).collect(Collectors.toList());
        if (travelGroups != null && travelGroups.size() > 0){
            for (TravelGroupDto travelGroup : travelGroups) {
                TravelGroupVo travelGroupVo = new TravelGroupVo();
                travelGroupVo.setGroupId(travelGroup.getGroupId());
                travelGroupVo.setGroupName(travelGroup.getGroupName());

                List<String> labelNameList = new ArrayList<>();
                List<TravelGroupLabel> travelGroupLabels = travelGroupLabelMapper.selectTravelGroupLabelByGroupId(travelGroup.getGroupId());
                if (travelGroupLabels != null && travelGroupLabels.size() > 0){
                    for (TravelGroupLabel travelGroupLabel : travelGroupLabels) {
                        labelNameList.add(travelGroupLabel.getGroupLabelName());
                    }
                }

                travelGroupVo.setLabelNameList(labelNameList);
                travelGroupVo.setGroupBanner(travelGroup.getGroupBanner());
                travelGroupVo.setGroupLinePrice(travelGroup.getGroupLinePrice());
                travelGroupVo.setVipGroupFee(travelGroup.getVipGroupFee());
                travelGroupVo.setGroupFee(travelGroup.getGroupFee());
                travelGroupVos.add(travelGroupVo);
            }

            return travelGroupVos;
        }
        else {
            throw new Exception("没有查到数据");
        }

    }

    /**
     * 旅游产品详情
     * */
    @Override
    public TravelGroupDetailsVo travelProductDetails(Long groupId) throws Exception
    {
        if (groupId != null && groupId != 0)
        {
            TravelGroupDetailsVo travelGroupDetailsVo = new TravelGroupDetailsVo();
            List<TravelGroupNumberDto> travelGroupNumberDtos = travelGroupNumberMapper.selectTravelGroupNumberDto(groupId);
            if (travelGroupNumberDtos != null && travelGroupNumberDtos.size() > 0)
            {
                List<Long> idList = new ArrayList<>();
                for (TravelGroupNumberDto travelGroupNumberDto : travelGroupNumberDtos)
                {
                    idList.add(travelGroupNumberDto.getNumberId());
                }
                List<OrderInfoDto> orderInfoDtos = orderInfoMapper.selectOrderInfoDtoList(idList);
                if (orderInfoDtos != null)
                {
                    travelGroupDetailsVo.setTravelersNumber(orderInfoDtos.size());
                } else
                {
                    travelGroupDetailsVo.setTravelersNumber(0);
                }
            } else
            {
                travelGroupDetailsVo.setTravelersNumber(0);
            }

            TravelGroup travelGroup = travelGroupMapper.selectTravelGroupById(groupId);
            if (travelGroup != null)
            {
                travelGroupDetailsVo.setGroupId(travelGroup.getGroupId());
                travelGroupDetailsVo.setGroupBanner(travelGroup.getGroupBanner());
                travelGroupDetailsVo.setVipGroupFee(travelGroup.getVipGroupFee());
                travelGroupDetailsVo.setGroupLinePrice(travelGroup.getGroupLinePrice());
                travelGroupDetailsVo.setGroupFee(travelGroup.getGroupFee());
//                TravelProductDto travelProductDto = travelProductMapper.selectTravelProduct(travelGroupDto.getGroupId());
//                travelGroupDto.ge
//                if (travelGroupDto != null){
//                    travelGroupDetailsVo.setCostPrice(travelProductDto.getCostPrice());
//                }
//                else {
//                    throw new Exception("没有指定旅游产品的价格信息");
//                }

                List<String> groupLabelNameList = new ArrayList<>();
                List<TravelGroupLabel> travelGroupLabels = travelGroupLabelMapper.selectTravelGroupLabelByGroupId(travelGroup.getGroupId());
                if (travelGroupLabels != null)
                {
                    for (TravelGroupLabel travelGroupLabel : travelGroupLabels)
                    {
                        groupLabelNameList.add(travelGroupLabel.getGroupLabelName());
                    }
                }
                travelGroupDetailsVo.setGroupLabelNameList(groupLabelNameList);
                travelGroupDetailsVo.setGroupName(travelGroup.getGroupName());


                List<TravelItinerarySummary> travelItinerarySummaries = travelItinerarySummaryMapper.selectTravelItinerarySummary(travelGroup.getGroupId());
                List<TravelItinerarySummaryVo> travelItinerarySummaryVoList = new ArrayList<>();
                if (travelItinerarySummaries != null && travelItinerarySummaries.size() > 0)
                {
                    for (TravelItinerarySummary travelItinerarySummary : travelItinerarySummaries)
                    {
                        TravelItinerarySummaryVo travelItinerarySummaryVo = new TravelItinerarySummaryVo();
                        travelItinerarySummaryVo.setItinerarySummaryId(travelItinerarySummary.getTravelItinerarySummaryId());
                        travelItinerarySummaryVo.setItinerarySummaryName(travelItinerarySummary.getTravelItinerarySummaryName());
                        travelItinerarySummaryVo.setLogoUrl(travelItinerarySummary.getLogoUrl());
                        travelItinerarySummaryVo.setItinerarySummaryDesc(travelItinerarySummary.getTravelItinerarySummaryDesc());
                        travelItinerarySummaryVoList.add(travelItinerarySummaryVo);
                    }
                }
                travelGroupDetailsVo.setTravelItinerarySummaryVoList(travelItinerarySummaryVoList);

                List<TravelItinerary> travelItineraries = travelItineraryMapper.selectTravelItinerary(travelGroup.getGroupId());
                List<ScheduleVo> schedule = new ArrayList<>();
                if (travelItineraries != null && travelItineraries.size() > 0)
                {
                    for (TravelItinerary travelItinerary : travelItineraries)
                    {
                        ScheduleVo scheduleVo = new ScheduleVo();
                        scheduleVo.setItineraryId(travelItinerary.getTravelItineraryId());
                        scheduleVo.setItineraryName(travelItinerary.getTravelItineraryName());

                        List<TravelItineraryInfo> travelItineraryInfos = travelItineraryInfoMapper.selectTravelItineraryInfo(travelItinerary.getTravelItineraryId());
                        List<ItineraryDetailsVo> itineraryDetailsVoList = new ArrayList<>();
                        if (travelItineraryInfos != null && travelItineraryInfos.size() > 0)
                        {
                            for (TravelItineraryInfo travelItineraryInfo : travelItineraryInfos)
                            {
                                ItineraryDetailsVo itineraryDetailsVo = new ItineraryDetailsVo();
                                itineraryDetailsVo.setInfoId(travelItineraryInfo.getTravelItineraryInfoId());
                                itineraryDetailsVo.setInfoName(travelItineraryInfo.getTravelItineraryInfoName());
                                itineraryDetailsVo.setInfoContent(travelItineraryInfo.getTravelItineraryInfoContent());
                                itineraryDetailsVo.setInfoDecs(travelItineraryInfo.getTravelItineraryInfoDecs());
                                itineraryDetailsVo.setInfoTips(travelItineraryInfo.getTravelItineraryInfoTips());

                                List<TravelItineraryPicture> travelItineraryPictures = travelItineraryPictureMapper.selectTravelItineraryPicture(travelItineraryInfo.getTravelItineraryInfoId());
                                List<TravelItineraryPictureVo> travelItineraryPictureVoList = new ArrayList<>();
                                if (travelItineraryPictures != null && travelItineraryPictures.size() > 0)
                                {
                                    for (TravelItineraryPicture travelItineraryPicture : travelItineraryPictures)
                                    {
                                        TravelItineraryPictureVo travelItineraryPictureVo = new TravelItineraryPictureVo();
                                        travelItineraryPictureVo.setPictureUrl(travelItineraryPicture.getPictureUrl());
                                        travelItineraryPictureVoList.add(travelItineraryPictureVo);
                                    }
                                }

                                itineraryDetailsVo.setTravelItineraryPictureVoList(travelItineraryPictureVoList);
                                itineraryDetailsVoList.add(itineraryDetailsVo);
                            }
                        }
                        scheduleVo.setItineraryDetailsVoList(itineraryDetailsVoList);
                        schedule.add(scheduleVo);
                    }
                }
                travelGroupDetailsVo.setSchedule(schedule);
                travelGroupDetailsVo.setProductFeature(travelGroup.getProductFeature());
                travelGroupDetailsVo.setCostMessage(travelGroup.getCostMessage());
                travelGroupDetailsVo.setReceptionStandard(travelGroup.getReceptionStandard());
                travelGroupDetailsVo.setHotelArrangement(travelGroup.getHotelArrangement());
                travelGroupDetailsVo.setWarmPrompt(travelGroup.getWarmPrompt());

                List<TravelComment> travelComments = travelCommentMapper.selectTravelComment(travelGroup.getGroupId());
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                Date date = new Date();
                if (travelComments != null && travelComments.size() > 0)
                {
                    for (TravelComment travelComment : travelComments)
                    {
                        Date createTime = format.parse(travelComment.getCreateTime());
                        Long timeNum = date.getTime() - createTime.getTime();
                        travelComment.setTimeNum(timeNum);
                    }
                    travelComments.sort((x, y) -> Double.compare(x.getTimeNum(), y.getTimeNum()));
                }
                if (travelComments.size() > 0)
                {
                    TravelCommentVo travelCommentVo = new TravelCommentVo();
                    travelCommentVo.setCommentId(travelComments.get(0).getCommentId());
                    travelCommentVo.setUserId(travelComments.get(0).getUserId());
                    travelCommentVo.setUserName(travelComments.get(0).getUserName());
                    travelCommentVo.setFaceurl(travelComments.get(0).getFaceurl());
                    travelCommentVo.setCommentContent(travelComments.get(0).getCommentContent());
                    travelCommentVo.setCommentScore(travelComments.get(0).getCommentScore().toString());
                    travelCommentVo.setCreateTime(travelComments.get(0).getCreateTime());
                    travelCommentVo.setCommentWith(travelComments.get(0).getCommentWith());
                    travelCommentVo.setCommentNum(travelComments.size());

                    List<TravelCommentPicture> travelCommentPictures = travelCommentPictureMapper.selectTravelCommentPicture(travelComments.get(0).getCommentId());
                    List<TravelCommentPictureVo> travelCommentPictureVoList = new ArrayList<>();
                    if (travelCommentPictures != null && travelCommentPictures.size() > 0)
                    {
                        for (TravelCommentPicture travelCommentPicture : travelCommentPictures)
                        {
                            TravelCommentPictureVo travelCommentPictureVo = new TravelCommentPictureVo();
                            travelCommentPictureVo.setPictureUrl(travelCommentPicture.getPictureUrl());
                            travelCommentPictureVoList.add(travelCommentPictureVo);
                        }
                    }
                    travelCommentVo.setTravelCommentPictureVoList(travelCommentPictureVoList);

                    travelGroupDetailsVo.setTravelCommentVo(travelCommentVo);
                }

                List<TravelGroupVo> travelGroupVos = travelGroupVoList();
                List<TravelGroupVo> travelGroupVoList = new ArrayList<>();
                for (TravelGroupVo travelGroupVo : travelGroupVos)
                {
                    if (travelGroupVo.getGroupId() != groupId)
                    {
                        travelGroupVoList.add(travelGroupVo);
                        if (travelGroupVoList.size() == 2)
                        {
                            break;
                        }
                    }
                }
                travelGroupDetailsVo.setTravelGroupVos(travelGroupVoList);
                return travelGroupDetailsVo;
            } else
            {
                throw new Exception("未查到指定id的旅游产品信息");
            }
        } else
        {
            throw new Exception("旅游产品id不能为空");
        }
    }

    /**
     * 查询指定旅游产品成团规则
     * */
    @Override
    public String selectTravelGroupByGroupId(Long groupId) throws Exception {
        if (groupId != null && groupId != 0){
            TravelGroup travelGroupDto = travelGroupMapper.selectTravelGroupById(groupId);
            if (travelGroupDto != null){
                return travelGroupDto.getGroupRows();
            }
            else {
                throw new Exception("未查到数据");
            }
        }
        else {
            throw new Exception("缺少必要参数");
        }
    }

    /**
     * 旅游填写订单
     * */
    @Override
    public GroupDetailsVo groupDetails(HttpServletRequest request, Long id, String setOffTime, String finishTime) {
        SimpleDateFormat format = new SimpleDateFormat("MM月dd日");
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

        GroupDetailsVo groupDetailsVo = new GroupDetailsVo();
        String token = request.getHeader("token");
        Customer customer = loginService.getLoginCustomerByToken(token);
        TravelGroup travelGroup = travelGroupMapper.selectTravelGroupById(id);
        BigDecimal bigDecimal = depositBusinessService.queyUserDepositBusiness(customer.getCustomerId());
        Long pointRecordValue = pointRecordService.dominateIntegral(customer.getCustomerId());
        List<TravelGroupNumberDto> travelGroupNumberDtos = travelGroupNumberMapper.selectTravelGroupNumberDto(id);
        List<CouponSpecific> couponSpecifics = couponSpecificMapper.selectCouponSpecificList(customer.getCustomerId());
        List<AssistProduct> assistProductList = assistProductMapper.travelInsuranceList();

        groupDetailsVo.setGroupId(travelGroup.getGroupId());
        groupDetailsVo.setGroupName(travelGroup.getGroupName());
        if (travelGroupNumberDtos.get(0).getStartTime() != null && travelGroupNumberDtos.get(0).getEndTime() != null){
//            String setOff = format.format(travelGroupNumberDtos.get(0).getStartTime());
//            String finish = format.format(travelGroupNumberDtos.get(0).getEndTime());
            groupDetailsVo.setTravelTime(setOffTime + "出发-" + finishTime);
        }
        groupDetailsVo.setCustomerName(customer.getCustomerName());
        groupDetailsVo.setCustomerPhone(customer.getContractPhoneOne());
        groupDetailsVo.setWechatId(customer.getWechatId());

        List<DiscountVo> amount = new ArrayList<>();
        if (couponSpecifics.size() > 0){
            for (CouponSpecific couponSpecific : couponSpecifics) {
                Coupon coupon = couponMapper.couponList(couponSpecific.getCouponId());
                if (coupon.getCouponStatus().equals("normal") && coupon.getCouponType().equals("CouponTypeTravel")){
                    DiscountVo discountVo = new DiscountVo();
                    discountVo.setCouponId(coupon.getCouponId());
                    discountVo.setCouponName(coupon.getCouponName());
                    discountVo.setCouponDiscount(coupon.getCouponDiscount().toString());
                    discountVo.setCouponMaxPrice(coupon.getCouponMaxprice().toString());
                    discountVo.setCouponPrice(coupon.getCouponPrice().toString());
                    discountVo.setInvalidTime(dateFormat.format(coupon.getInvalidTime()));
                    amount.add(discountVo);
                }
            }
        }

        List<InsuranceVo> insuranceVoList = new ArrayList<>();
        if (assistProductList.size() > 0){
            for (AssistProduct assistProduct : assistProductList) {
                InsuranceVo insuranceVo = new InsuranceVo();
                insuranceVo.setId(assistProduct.getId());
                insuranceVo.setName(assistProduct.getName());
                insuranceVo.setSalePrice(assistProduct.getSalePrice().toString());
                insuranceVo.setIsCheck(assistProduct.getIscheck());
                insuranceVo.setDescribe(assistProduct.getDescribe());
                insuranceVo.setExplain(assistProduct.getExplain());
                insuranceVoList.add(insuranceVo);
            }
        }
        groupDetailsVo.setInsuranceVoList(insuranceVoList);
        groupDetailsVo.setAmount(amount);
        if (bigDecimal != null){
            groupDetailsVo.setGold(bigDecimal.toString());
        }
        groupDetailsVo.setVipGroupFee(travelGroup.getVipGroupFee());
        groupDetailsVo.setGroupFee(travelGroup.getGroupFee());
        groupDetailsVo.setPointRecordValue(new BigDecimal(pointRecordValue));
        return groupDetailsVo;
    }

    /**
     * 新建团产品
     * */
    @Override
    public int insertProduct(HttpServletRequest request, InsertProductVo insertProductVo) throws Exception
    {

        Employee loginEmployee = loginService.getLoginEmployee(request);
        if (loginEmployee == null)
        {
            throw new Exception("登录已过期");
        }

        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
        Date date = new Date();

        Long groupId = System.currentTimeMillis() / 1000;
        TravelGroup travelGroup = new TravelGroup();
        travelGroup.setGroupId(groupId);
        travelGroup.setSupplierId(insertProductVo.getInsertGroupVo().getSupplierId());
        travelGroup.setContractId(insertProductVo.getInsertGroupVo().getContractId());
        travelGroup.setGroupName(insertProductVo.getInsertGroupVo().getGroupName());
        travelGroup.setCountryType(insertProductVo.getInsertGroupVo().getGroupType());
        travelGroup.setGroupStatus("wait");
        travelGroup.setGroupFee(insertProductVo.getCostMaintenance().getGroupFee());
        travelGroup.setVipGroupFee(insertProductVo.getCostMaintenance().getCustomerGroupFee());

        String guestGroupFee = "";
        for (int i = 0; i < insertProductVo.getCostMaintenance().getGroupFeeList().size(); i++)
        {
            if (i == 0)
            {
                guestGroupFee = insertProductVo.getCostMaintenance().getGroupFeeList().get(i).toString();
            } else
            {
                guestGroupFee = guestGroupFee + "|" + insertProductVo.getCostMaintenance().getGroupFeeList().get(i).toString();
            }
        }
        travelGroup.setGuestGroupFee(guestGroupFee);
        travelGroup.setChdFee(insertProductVo.getCostMaintenance().getChildGroupFee());
        travelGroup.setInfFee(insertProductVo.getCostMaintenance().getBabyGroupFee());
        travelGroup.setCashPledge(insertProductVo.getCostMaintenance().getMargin());
        travelGroup.setVipCashPledge(insertProductVo.getCostMaintenance().getCustomerMargin());
        travelGroup.setGuestCashPledge(insertProductVo.getCostMaintenance().getMarginList());
        travelGroup.setTransportation(insertProductVo.getCostMaintenance().getTransportation());
        travelGroup.setComplaintFee(insertProductVo.getCostMaintenance().getCompensation());
        travelGroup.setAduAgeStart(insertProductVo.getRuleMaintenance().getAldultAge());
        travelGroup.setAduAgeEnd(insertProductVo.getRuleMaintenance().getAldultAgeBack());
        travelGroup.setAduCount(insertProductVo.getRuleMaintenance().getAldultGroupLimit());
        travelGroup.setChdAgeStart(insertProductVo.getRuleMaintenance().getChildAge());
        travelGroup.setChdAgeEnd(insertProductVo.getRuleMaintenance().getChildAgeBack());
        travelGroup.setChdCount(insertProductVo.getRuleMaintenance().getChildGroupLimit());
        travelGroup.setChdOrderCount(insertProductVo.getRuleMaintenance().getChildOrderLimit());
        travelGroup.setInfAgeStart(insertProductVo.getRuleMaintenance().getBabyAge());
        travelGroup.setInfAgeEnd(insertProductVo.getRuleMaintenance().getBabyAgeBack());
        travelGroup.setInfCount(insertProductVo.getRuleMaintenance().getBabyGroupLimit());
        travelGroup.setInfOrderCount(insertProductVo.getRuleMaintenance().getBabyOrderLimit());
        travelGroup.setVipDiscountUsed(insertProductVo.getPreferentialPolicies().getDiscount());
        if (insertProductVo.getPreferentialPolicies().getAccompanying().equals("true"))
        {
            String guestDiscountUsed = "";
            for (int i = 0; i < insertProductVo.getPreferentialPolicies().getDiscountList().size(); i++)
            {
                if (i == 0)
                {
                    guestDiscountUsed = insertProductVo.getPreferentialPolicies().getDiscountList().get(i).toString();
                } else
                {
                    guestDiscountUsed = guestDiscountUsed + "|" + insertProductVo.getPreferentialPolicies().getDiscountList().get(i).toString();
                }
            }
            travelGroup.setGuestDiscountUsed(guestDiscountUsed);
        }
        travelGroup.setGroupBanner(insertProductVo.getUrl());
        travelGroup.setTourItinerary(insertProductVo.getStaffExhibit().getItinerary());
        travelGroup.setServiceStandard(insertProductVo.getStaffExhibit().getServiceStandards());
        travelGroup.setFeeContain(insertProductVo.getStaffExhibit().getIncludeItems());
        travelGroup.setFeeNoContain(insertProductVo.getStaffExhibit().getDoesNotContain());
        travelGroup.setTravelNotes(insertProductVo.getStaffExhibit().getTravelInformation());
        travelGroup.setFlightRefundRule(insertProductVo.getStaffExhibit().getReserve());
        travelGroup.setOwnFeePlaceInfo(insertProductVo.getStaffExhibit().getAttractions());
        travelGroup.setShopPlace(insertProductVo.getStaffExhibit().getShopping());
        travelGroup.setUserTourItinerary(insertProductVo.getUserExhibit().getItinerary());
        travelGroup.setUserServiceStandard(insertProductVo.getUserExhibit().getServiceStandards());
        travelGroup.setUserFeeContain(insertProductVo.getUserExhibit().getIncludeItems());
        travelGroup.setUserFeeNoContain(insertProductVo.getUserExhibit().getDoesNotContain());
        travelGroup.setUserTravelNotes(insertProductVo.getUserExhibit().getTravelInformation());
        travelGroup.setUserFlightRefundRule(insertProductVo.getUserExhibit().getReserve());
        travelGroup.setUserOwnFeePlaceInfo(insertProductVo.getUserExhibit().getAttractions());
        travelGroup.setUserShopPlace(insertProductVo.getUserExhibit().getShopping());
        travelGroup.setProductFeature(insertProductVo.getStaffExhibit().getProductFeature());
        travelGroup.setCostMessage(insertProductVo.getStaffExhibit().getCostMessage());
        travelGroup.setReceptionStandard(insertProductVo.getStaffExhibit().getReceptionStandard());
        travelGroup.setHotelArrangement(insertProductVo.getStaffExhibit().getHotelArrangement());
        travelGroup.setWarmPrompt(insertProductVo.getStaffExhibit().getWarmPrompt());
        travelGroup.setBookingNotes(insertProductVo.getStaffExhibit().getBookingNotes());
        travelGroup.setCreateTime(date);
        travelGroup.setOperateTime(date);
        int i = travelGroupMapper.insertProduct(travelGroup);
        if (i <= 0)
        {
            throw new Exception("添加失败");
        }
        if (insertProductVo.getTravelItinerarySummaryVoList().size() > 0)
        {
            insertProductVo.getTravelItinerarySummaryVoList().forEach(item -> item.setGroupId(travelGroup.getGroupId()));
            travelItinerarySummaryMapper.insertBatch(insertProductVo.getTravelItinerarySummaryVoList());
        }
        if (insertProductVo.getGroupLabelNameList().size() > 0)
        {
            for (TravelGroupLabel travelGroupLabel : insertProductVo.getGroupLabelNameList())
            {
                travelGroupLabel.setGroupId(travelGroup.getGroupId());
                travelGroupLabelMapper.insertTravelGroupLabel(travelGroupLabel);
            }
        }
        if (insertProductVo.getSchedule().size() > 0)
        {
            for (TravelItinerary travelItinerary :insertProductVo.getSchedule())
            {
                travelItinerary.setGroupId(travelGroup.getGroupId());
                travelItineraryMapper.insertTravelItinerary(travelItinerary);
                for (TravelItineraryInfo travelItineraryInfo :travelItinerary.getItineraryDetailsVoList())
                {
                    travelItineraryInfo.setTravelItineraryId(travelItinerary.getTravelItineraryId());
                    travelItineraryInfoMapper.insertTravelItineraryInfo(travelItineraryInfo);
                    for (TravelItineraryPicture travelItineraryPicture : travelItineraryInfo.getTravelItineraryPictureVoList())
                    {
                        travelItineraryPicture.setTravelItineraryInfoId(travelItineraryInfo.getTravelItineraryInfoId());
                        travelItineraryPictureMapper.insertTravelItineraryPicture(travelItineraryPicture);
                    }
                }
            }
        }
        TravelGroupNumber travelGroupNumber = new TravelGroupNumber();
        travelGroupNumber.setGroupId(groupId);
        travelGroupNumber.setSupplierId(insertProductVo.getInsertGroupVo().getSupplierId());
        travelGroupNumber.setContractId(insertProductVo.getInsertGroupVo().getContractId());
        travelGroupNumber.setGroupName(insertProductVo.getInsertGroupVo().getGroupName());
        travelGroupNumber.setGroupNumber(insertProductVo.getInsertGroupVo().getGroupPrefix() + format.format(date));
        Date startDate = new Date();
        Date endDate = DateUtils.addMonths(startDate, 1);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        travelGroupNumber.setStartTime(sdf.parse(sdf.format(startDate)));
        travelGroupNumber.setEndTime(sdf.parse(sdf.format(endDate)));
        travelGroupNumber.setNumberStatus("2");
        travelGroupNumber.setCreateTime(date);
        travelGroupNumber.setEmployeeId(loginEmployee.getEmployeeId());
        travelGroupNumber.setPrice(insertProductVo.getInsertGroupVo().getPrice());
        travelGroupNumber.setNumberDate(sdf.parse(sdf.format(endDate)));
        i = travelGroupNumberMapper.insertGroupNum(travelGroupNumber);
        return i;
    }

    /**
     * 查询待修改的团
     * */
    @Override
    public InsertProductVo updateGroup(Long id) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        InsertProductVo insertProductVo = new InsertProductVo();
        InsertGroupVo insertGroupVo = new InsertGroupVo();
        CostMaintenance costMaintenance = new CostMaintenance();
        RuleMaintenance ruleMaintenance = new RuleMaintenance();
        PreferentialPolicies preferentialPolicies = new PreferentialPolicies();
        Exhibit userExhibit = new Exhibit();
        Exhibit staffExhibit = new Exhibit();
        TravelGroup travelGroup = travelGroupMapper.selectTravelGroup(id);
        if (travelGroup != null){
            insertProductVo.setUrl(travelGroup.getGroupBanner());

            List<TravelGroupNumberDto> travelGroupNumberDtos = travelGroupNumberMapper.selectTravelGroupNumberDto(travelGroup.getGroupId());
            if (travelGroupNumberDtos != null && travelGroupNumberDtos.size() > 0){
                for (TravelGroupNumberDto travelGroupNumberDto : travelGroupNumberDtos) {
                    if (travelGroupNumberDto.getNumberDate() != null){
                        travelGroupNumberDto.setNumberTime(format.format(travelGroupNumberDto.getNumberDate()));
                    }
                    if (travelGroupNumberDto.getStartTime() != null){
                        travelGroupNumberDto.setStartDate(format.format(travelGroupNumberDto.getStartTime()));
                    }
                    if (travelGroupNumberDto.getEndTime() != null){
                        travelGroupNumberDto.setEndDate(format.format(travelGroupNumberDto.getEndTime()));
                    }
                }
            }
            insertGroupVo.setTravelGroupNumberDtoList(travelGroupNumberDtos);
            if (travelGroup.getSupplierId() != null && travelGroup.getSupplierId() != 0){
                TravelSupplier travelSupplier = travelSupplierMapper.travelSupplierById(travelGroup.getSupplierId());
                if (travelSupplier != null){
                    insertGroupVo.setSupplierName(travelSupplier.getSupplierName());
                }
                insertGroupVo.setSupplierId(travelGroup.getSupplierId());
            }
            if (travelGroup.getContractId() != null && travelGroup.getContractId() != 0){
                TravelContractDto travelContractDto = travelContractMapper.selectTravelContractById(travelGroup.getContractId());
                if (travelContractDto != null){
                    insertGroupVo.setContractNum(travelContractDto.getContractNum());
                }
                insertGroupVo.setContractId(travelGroup.getContractId());
            }
            insertGroupVo.setGroupType(travelGroup.getCountryType());
            insertGroupVo.setGroupName(travelGroup.getGroupName());

            costMaintenance.setGroupFee(travelGroup.getGroupFee());
            costMaintenance.setCustomerGroupFee(travelGroup.getVipGroupFee());

            List<BigDecimal> groupFeeList = new ArrayList<>();
            if (travelGroup.getGuestGroupFee() != null && !travelGroup.getGuestGroupFee().equals("")){
                int i = travelGroup.getGuestGroupFee().indexOf("|");
                if (i == -1){
                    groupFeeList.add(new BigDecimal(travelGroup.getGuestGroupFee()));
                }
                else {
                    String[] split = travelGroup.getGuestGroupFee().split("|");
                    for (String s : split) {
                        groupFeeList.add(new BigDecimal(s));
                    }
                }
            }
            costMaintenance.setGroupFeeList(groupFeeList);
            costMaintenance.setChildGroupFee(travelGroup.getChdFee());
            costMaintenance.setBabyGroupFee(travelGroup.getInfFee());
            costMaintenance.setMargin(travelGroup.getCashPledge());
            costMaintenance.setCustomerMargin(travelGroup.getVipCashPledge());
            costMaintenance.setMarginList(travelGroup.getGuestCashPledge());
            costMaintenance.setTransportation(travelGroup.getTransportation());
            costMaintenance.setCompensation(travelGroup.getComplaintFee());

            ruleMaintenance.setAldultAge(travelGroup.getAduAgeStart());
            ruleMaintenance.setAldultAgeBack(travelGroup.getAduAgeEnd());
            ruleMaintenance.setAldultGroupLimit(travelGroup.getAduCount());
            ruleMaintenance.setChildAge(travelGroup.getChdAgeStart());
            ruleMaintenance.setChildAgeBack(travelGroup.getChdAgeEnd());
            ruleMaintenance.setChildGroupLimit(travelGroup.getChdCount());
            ruleMaintenance.setChildOrderLimit(travelGroup.getChdOrderCount());
            ruleMaintenance.setBabyAge(travelGroup.getInfAgeStart());
            ruleMaintenance.setBabyAgeBack(travelGroup.getInfAgeEnd());
            ruleMaintenance.setBabyGroupLimit(travelGroup.getInfCount());
            ruleMaintenance.setBabyOrderLimit(travelGroup.getInfOrderCount());

            preferentialPolicies.setDiscount(travelGroup.getVipDiscountUsed());

            if (travelGroup.getGuestDiscountUsed() != null && !travelGroup.getGuestDiscountUsed().equals("")){
                preferentialPolicies.setAccompanying("true");
                List<BigDecimal> discountList = new ArrayList<>();
                int i = travelGroup.getGuestDiscountUsed().indexOf("|");
                if (i == -1){
                    discountList.add(new BigDecimal(travelGroup.getGuestDiscountUsed()));
                }
                else {
                    String[] split = travelGroup.getGuestDiscountUsed().split("|");
                    for (String s : split) {
                        discountList.add(new BigDecimal(s));
                    }
                }
                preferentialPolicies.setDiscountList(discountList);
            }
            else {
                preferentialPolicies.setAccompanying("false");
            }

            userExhibit.setItinerary(travelGroup.getUserTourItinerary());
            userExhibit.setServiceStandards(travelGroup.getUserServiceStandard());
            userExhibit.setIncludeItems(travelGroup.getUserFeeContain());
            userExhibit.setDoesNotContain(travelGroup.getUserFeeNoContain());
            userExhibit.setTravelInformation(travelGroup.getUserTravelNotes());
            userExhibit.setReserve(travelGroup.getUserFlightRefundRule());
            userExhibit.setAttractions(travelGroup.getUserOwnFeePlaceInfo());
            userExhibit.setShopping(travelGroup.getUserShopPlace());

            staffExhibit.setItinerary(travelGroup.getTourItinerary());
            staffExhibit.setServiceStandards(travelGroup.getGroupRefundRule());
            staffExhibit.setIncludeItems(travelGroup.getFeeContain());
            staffExhibit.setDoesNotContain(travelGroup.getFeeNoContain());
            staffExhibit.setTravelInformation(travelGroup.getTravelNotes());
            staffExhibit.setReserve(travelGroup.getFlightRefundRule());
            staffExhibit.setAttractions(travelGroup.getOwnFeePlaceInfo());
            staffExhibit.setShopping(travelGroup.getShopPlace());
        }
        insertProductVo.setInsertGroupVo(insertGroupVo);
        insertProductVo.setCostMaintenance(costMaintenance);
        insertProductVo.setRuleMaintenance(ruleMaintenance);
        insertProductVo.setPreferentialPolicies(preferentialPolicies);
        insertProductVo.setUserExhibit(userExhibit);
        insertProductVo.setStaffExhibit(staffExhibit);
        return insertProductVo;
    }

    /**
     * 修改团
     * */
    @Override
    public int group(InsertProductVo insertProductVo) throws Exception {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        if (insertProductVo.getInsertGroupVo().getTravelGroupNumberDtoList() != null &&
                insertProductVo.getInsertGroupVo().getTravelGroupNumberDtoList().size() > 0){
            for (TravelGroupNumberDto travelGroupNumberDto : insertProductVo.getInsertGroupVo().getTravelGroupNumberDtoList()) {
                if (travelGroupNumberDto.getNumberTime() != null){
                    try {
                        travelGroupNumberDto.setNumberDate(format.parse(travelGroupNumberDto.getNumberTime()));
                    } catch (Exception e){
                        throw new Exception("日期转换错误" + travelGroupNumberDto.getNumberTime());
                    }
                }
                if (travelGroupNumberDto.getStartDate() != null){
                    try {
                        travelGroupNumberDto.setStartTime(format.parse(travelGroupNumberDto.getStartDate()));
                    } catch (Exception e){
                        throw new Exception("日期转换错误" + format.parse(travelGroupNumberDto.getStartDate()));
                    }
                }
                if (travelGroupNumberDto.getEndDate() != null){
                    try {
                        travelGroupNumberDto.setEndTime(format.parse(travelGroupNumberDto.getEndDate()));
                    } catch (Exception e){
                        throw new Exception("日期转换错误" + travelGroupNumberDto.getEndDate());
                    }
                }
                int i = travelGroupNumberMapper.updateTravelGroupNumber(travelGroupNumberDto);
                if (i <= 0){
                    throw new Exception("团号修改失败" + travelGroupNumberDto.getGroupNumber());
                }
            }
        }

        TravelGroup travelGroup = new TravelGroup();
        travelGroup.setGroupId(insertProductVo.getId());
        travelGroup.setSupplierId(insertProductVo.getInsertGroupVo().getSupplierId());
        travelGroup.setContractId(insertProductVo.getInsertGroupVo().getContractId());
        travelGroup.setGroupName(insertProductVo.getInsertGroupVo().getGroupName());
        travelGroup.setCountryType(insertProductVo.getInsertGroupVo().getGroupType());
        travelGroup.setGroupStatus(insertProductVo.getInsertGroupVo().getNumberStatus().toString());
        travelGroup.setVipGroupFee(insertProductVo.getCostMaintenance().getCustomerGroupFee());

        String guestGroupFee = "";
        for (int i = 0 ; i < insertProductVo.getCostMaintenance().getGroupFeeList().size() ; i++) {
            if (i == 0){
                guestGroupFee = insertProductVo.getCostMaintenance().getGroupFeeList().get(i).toString();
            }
            else {
                guestGroupFee = guestGroupFee + "|" + insertProductVo.getCostMaintenance().getGroupFeeList().get(i).toString();
            }
        }
        travelGroup.setGuestGroupFee(guestGroupFee);
        travelGroup.setGroupFee(insertProductVo.getCostMaintenance().getGroupFee());
        travelGroup.setChdFee(insertProductVo.getCostMaintenance().getChildGroupFee());
        travelGroup.setInfFee(insertProductVo.getCostMaintenance().getBabyGroupFee());
        travelGroup.setCashPledge(insertProductVo.getCostMaintenance().getMargin());
        travelGroup.setVipCashPledge(insertProductVo.getCostMaintenance().getCustomerMargin());
        travelGroup.setGuestCashPledge(insertProductVo.getCostMaintenance().getMarginList());
        travelGroup.setTransportation(insertProductVo.getCostMaintenance().getTransportation());
        travelGroup.setComplaintFee(insertProductVo.getCostMaintenance().getCompensation());
        travelGroup.setAduAgeStart(insertProductVo.getRuleMaintenance().getAldultAge());
        travelGroup.setAduAgeEnd(insertProductVo.getRuleMaintenance().getAldultAgeBack());
        travelGroup.setAduCount(insertProductVo.getRuleMaintenance().getAldultGroupLimit());
        travelGroup.setChdAgeStart(insertProductVo.getRuleMaintenance().getChildAge());
        travelGroup.setChdAgeEnd(insertProductVo.getRuleMaintenance().getChildAgeBack());
        travelGroup.setChdCount(insertProductVo.getRuleMaintenance().getChildGroupLimit());
        travelGroup.setChdOrderCount(insertProductVo.getRuleMaintenance().getChildOrderLimit());
        travelGroup.setInfAgeStart(insertProductVo.getRuleMaintenance().getBabyAge());
        travelGroup.setInfAgeEnd(insertProductVo.getRuleMaintenance().getBabyAgeBack());
        travelGroup.setInfCount(insertProductVo.getRuleMaintenance().getBabyGroupLimit());
        travelGroup.setInfOrderCount(insertProductVo.getRuleMaintenance().getBabyOrderLimit());
        travelGroup.setVipDiscountUsed(insertProductVo.getPreferentialPolicies().getDiscount());
        if (insertProductVo.getPreferentialPolicies().getAccompanying() != null &&
                insertProductVo.getPreferentialPolicies().getAccompanying().equals("true")){
            String guestDiscountUsed = "";
            for (int i = 0; i < insertProductVo.getPreferentialPolicies().getDiscountList().size(); i++) {
                if (i == 0){
                    guestDiscountUsed = insertProductVo.getPreferentialPolicies().getDiscountList().get(i).toString();
                }
                else {
                    guestDiscountUsed = guestGroupFee + "|" + insertProductVo.getPreferentialPolicies().getDiscountList().get(i).toString();
                }
            }
            travelGroup.setGuestDiscountUsed(guestDiscountUsed);
        }
        travelGroup.setGroupBanner(insertProductVo.getUrl());
        travelGroup.setUserTourItinerary(insertProductVo.getUserExhibit().getItinerary());
        travelGroup.setTourItinerary(insertProductVo.getStaffExhibit().getItinerary());
        travelGroup.setUserServiceStandard(insertProductVo.getUserExhibit().getServiceStandards());
        travelGroup.setServiceStandard(insertProductVo.getStaffExhibit().getServiceStandards());
        travelGroup.setUserFeeContain(insertProductVo.getUserExhibit().getIncludeItems());
        travelGroup.setFeeContain(insertProductVo.getStaffExhibit().getIncludeItems());
        travelGroup.setUserFeeNoContain(insertProductVo.getUserExhibit().getDoesNotContain());
        travelGroup.setFeeNoContain(insertProductVo.getStaffExhibit().getDoesNotContain());
        travelGroup.setUserTravelNotes(insertProductVo.getUserExhibit().getTravelInformation());
        travelGroup.setTravelNotes(insertProductVo.getStaffExhibit().getTravelInformation());
        travelGroup.setUserFlightRefundRule(insertProductVo.getUserExhibit().getReserve());
        travelGroup.setFlightRefundRule(insertProductVo.getStaffExhibit().getReserve());
        travelGroup.setUserOwnFeePlaceInfo(insertProductVo.getUserExhibit().getAttractions());
        travelGroup.setOwnFeePlaceInfo(insertProductVo.getStaffExhibit().getAttractions());
        travelGroup.setUserShopPlace(insertProductVo.getUserExhibit().getShopping());
        travelGroup.setShopPlace(insertProductVo.getStaffExhibit().getShopping());
        int i = travelGroupMapper.group(travelGroup);
        return i;
    }
}
